#include <iostream>
using namespace std;

int main() {
	const int N = 1e5;
	int cost[N];
	int dp[N];

	dp[0] = 0;
	dp[1] = 0;

	int n;
	cin >> n;

	for (int i = 0; i < n; ++i)
		scanf("%d", &cost[i]);

	for (int i = 2; i <= n; ++i)
	{
		dp[i] = min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
	}
	cout << dp[n] << endl;
	return 0;
}